import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
//
// const duration = require('dayjs/plugin/duration');
dayjs.extend(duration);

export function getDuration(milliseconds: number) {
	const du = dayjs.duration(milliseconds);

	if (milliseconds < 60 * 1000) {
		return [Math.floor(du.asSeconds()), "秒"];
	} else if (milliseconds < 3600 * 1000) {
		return [Math.floor(du.asMinutes()), "分"];
	} else {
		return [Math.floor(du.asHours()).toFixed(1), "小时"];
	}
}
